<?php  
class ControllerCommonHome extends Controller {
	public function index() {
		$this->load->model('design/layout');
		
		$this->document->setTitle($this->config->get('config_title'));
		$this->document->setDescription($this->config->get('config_meta_description'));

		$this->data['heading_title'] = $this->config->get('config_title');
		
		$route = 'common/home';

		$layout_id = $this->model_design_layout->getLayout($route);
		
		$this->data['modules'] = array();
		
		$this->load->model('setting/extension');
		
		$extensions = $this->model_setting_extension->getExtensions('module');
		
		foreach ($extensions as $extension) {
			$modules = $this->config->get($extension['code'] . '_module');
				
			if ($modules) {
				foreach ($modules as $module) {
					if ($module['layout_id'] == $layout_id && $module['position'] == 'content' && $module['status']) {
						$this->data['modules'][$extension['code']][] = array(
							'setting'    => $module,
							'module'	 =>	$this->getChild('module/' . $extension['code'], $module)
						);
					}
				}
			}
		}
		
		if (file_exists(DIR_TEMPLATE . $this->config->get('config_template') . '/template/common/home.tpl')) {
			$this->template = $this->config->get('config_template') . '/template/common/home.tpl';
		} else {
			$this->template = 'default/template/common/home.tpl';
		}
		
		$this->children = array(
			'common/content_top',
			'common/content_bottom',
			'common/footer',
			'common/header'
		);
										
		$this->response->setOutput($this->render());
	}
}
?>